package zdh.fsy.jjwcVehicle.rxx.processmsg;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.Setter;

@Setter
public class VehicleStateData {
  /**
   * vehicle current position
   */
  @Getter
  @JsonProperty(required = true, value = "cur_node_id")
  private String currentPosition;
  /**
   * the vehicle power
   */
  @Getter
  @JsonProperty(required = true)
  private Integer power;

  @Getter
  @JsonProperty(required = true, value = "suspend")
  private Boolean isPause;
  /**
   * is idle,0:true,1:false
   */
  @JsonProperty(required = true, value = "release")
  private Integer isIdle;

  /**
   * The accuracy of SLAM positioning
   */
  @Getter
  @JsonProperty(required = true)
  private Float location_score;

  /**
   * The ID set of completed paths
   */
  @Getter
  @JsonProperty(required = true,value = "path_list")
  private List<Integer> finishPathIds;

  @Getter
  @JsonProperty(required = true,value = "action_list")
  private List<ActionResult> finishActions;

  /**
   * 0: idle,1:success,2:failed
   */
  @JsonProperty(required = true, value = "path_arrive_status")
  private Integer vehicleAllPathState;

  @JsonProperty(required = true, value = "action_complete_status")
  private Integer vehicleAllActionState;

  /**
   * 0：no charge,1: charging
   */
  @JsonProperty(required = true, value = "auto_charge")
  private Integer isCharging;


  @JsonProperty(required = true, value = "alarminfo")
  private String warningMsg;

  @Getter
  @JsonProperty(required = true)
  private double x;

  @Getter
  @JsonProperty(required = true)
  private double y;

  @Getter
  @JsonProperty(required = true,value = "linear_w")
  private double angularVelocity;

  @Getter
  @JsonProperty(required = true,value = "linear_x")
  private double linearVelocity;

  @Getter
  @JsonProperty(required = true,value = "angle")
  private double angle;

  @Getter
  private String action_release;

  @Getter
  private Float battery_current;

  @Getter
  private String last_node_id;


  @Getter
  private Integer car_model;


  @Getter
  private Integer fork_status;

  @Getter
  private Float fork_height;

  @Getter
  private Boolean load_status;

  @Getter
  private String qr_code_id;

  @Getter
  private String mapcode;

  @Getter
  private String task_failed_msg;

  @Getter
  private Integer location_mode;

  @Getter
  private Float battery_voltage;

  @Getter
  private Float battery_temperature;

  @Getter
  private Integer battery_type;

  @Getter
  private Float charge_max_current;

  @Getter
  private  Float charge_max_voltage;

  @Getter
  private Float rotate_device_angle;

  @Getter
  private Integer robot_work_type;


  //没有的字段

  @Getter
  private Boolean charge_ready_status;

  @Getter
  private String qr_code;


  @Getter
  private  List<String> robot_in_path;

  @Getter
  private Float total_mileage;


  @Getter
  private Float shelf_angle;













  public Boolean isIdle() {
    return this.isIdle == 0;
  }

  /**
   * if vehicleAllPathState is not equal  2 then return true
   *
   * @return
   */
  public Boolean vehiclePathSuccessFinished() {
    return this.vehicleAllPathState != 2;
  }

  public Boolean vehicleActionSuccessFinished() {
    return this.vehicleAllActionState != 2;
  }

  public Boolean vehicleIsCharging() {
    return this.isCharging == 1;
  }

  public List<String> getWarningMsg() {
    ArrayList<String> result = new ArrayList<>();
    if (this.warningMsg != null) {
      String[] split = warningMsg.split(";");
      result.addAll(Arrays.asList(split));
    }
    return result;
  }

  @Override
  public String toString() {
    return "VehicleStateData{" +
           "currentPosition='" + currentPosition + '\'' +
           ", power=" + power +
           ", isPause=" + isPause +
           ", isIdle=" + isIdle +
           ", location_score=" + location_score +
           ", finishPathIds=" + finishPathIds +
           ", finishActions=" + finishActions +
           ", vehicleAllPathState=" + vehicleAllPathState +
           ", vehicleAllActionState=" + vehicleAllActionState +
           ", isCharging=" + isCharging +
           ", warningMsg='" + warningMsg + '\'' +
           '}';
  }
}
